package com.example.a12502.aihome;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.Toolbar;

import com.example.a12502.aihome.equipment.EquipmentBean;
import com.example.a12502.aihome.equipment.EquipmentListViewAdapter;
import com.example.a12502.aihome.home.ListViewAdapter;

import java.util.ArrayList;
import java.util.HashMap;

public class EquipmentFragment extends Fragment implements View.OnClickListener{
    ArrayList<HashMap<String,Object>> arrayList;
    EquipmentListViewAdapter eListViewAdapter;

    ListView eList;

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_equipment, container, false);

        //Toolbar toolbar = (Toolbar)view.findViewById(R.id.toolbar);
        eList=view.findViewById(R.id.elist);
        eListViewAdapter=new EquipmentListViewAdapter(this.getContext(),getData());
        eList.setAdapter(eListViewAdapter);
        eList.setFocusable(false);


        return view;

    }

    private ArrayList<HashMap<String, Object>> getData() {
        arrayList = new ArrayList<>();
        HashMap<String,Object> hashMap=new HashMap<>();
        HashMap<String,Object> hashMap1=new HashMap<>();
        HashMap<String,Object> hashMap2=new HashMap<>();
        hashMap.put("ename","型号T-001");
        hashMap.put("estatus","运行正常");
        hashMap.put("linktext","WIFI连接");
        hashMap.put("econtrol",R.mipmap.ebutton1);
        hashMap.put("linkstatus",R.mipmap.connected);

        hashMap1.put("ename","型号T-002");
        hashMap1.put("estatus","运行正常");
        hashMap1.put("linktext","蓝牙连接");
        hashMap1.put("econtrol",R.mipmap.ebutton2);
        hashMap1.put("linkstatus",R.mipmap.connected);

        hashMap2.put("ename","型号T-003");
        hashMap2.put("estatus","运行故障");
        hashMap2.put("linktext","WIFI连接");
        hashMap2.put("econtrol",R.mipmap.ebutton3);
        hashMap2.put("linkstatus",R.mipmap.connected);


        arrayList.add(hashMap);
        arrayList.add(hashMap1);
        arrayList.add(hashMap2);

        return arrayList;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        }
    }

}
